<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>

    // 1.创建对象的方式一
    var stu1 = {
      name: '',
      age: 100,
      height: 188,
      running: function () {
        console.log('running')
      }
    }
    console.log(stu1)
    // 2.创建对象方式二
    function createStu(name, age, height) {
      var stu = {}
      stu.name = name
      stu.age = age
      stu.height = height
      stu.running = function () {
        console.log('running')
      }
      return stu
    }
    var stu2 = createStu('zhangsan',20,176)
    console.log(stu2)
    // 3.创建对象的方式三
    function Student(name, age, height) {
      this.name = name
      this.age = age
      this.height = height
      this.running = function () {
        console.log('running')
      }
    }
    var stu3 = new Student('kobe',18,1.88)
    console.log(stu3)
  </script>
</body>

</html>